package org.csu.mypetstore_seller.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.csu.mypetstore_seller.domain.Category;
import org.csu.mypetstore_seller.persistence.CategoryMapper;
import org.csu.mypetstore_seller.persistence.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.sql.Wrapper;
import java.util.List;


@Service
public class CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    //得到所有商品分类列表
    public List<Category> getCategory(){
        return categoryMapper.selectList(null);
    }

    public void insertCategory(Category category) {
        categoryMapper.insert(category);
    }

    public void deleteCategoryByName(String name) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("name", name);//设置条件name字段等于传入的名称
        categoryMapper.delete(queryWrapper);
    }
}